<template>
  <div class="container">
    <div class="login-bg">
        <section class="hd login-box">
          <h1 class="login-title">用户登录</h1>
          <div class="login-content">
              <div>
                手机号：<Input v-model="username"  placeholder="工号/手机号" prefix="ios-contact" style="width:300px;"/>
              </div>
              <div class="mt20">
                验证码：<Input v-model="password"  type="password" placeholder="请输入密码" prefix="ios-key" style="width:300px;"/>
              </div>
              <div class="text-center" style="width:346px;margin-top:40px;">
                <Button type="primary" long  @click="login" :loading="loading" >
                  {{loading ? '正在登陆中...' : '登录'}}
                </Button>
              </div>
              <div class="text-right" style="width:346px;margin-top:10px;">
                <router-link to="/modifyPassword">忘记密码？</router-link>
              </div>
          </div>
        </section>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      carousel: 0,
      username: '',
      password: '',
      loading: false
    };
  },
  mounted() {
    // this.login();
  },
  methods: {
    login() {
      this.loading = true
      this.$post("login").then(res => {
        this.loading = false
        if (res.code === 200) {
          localStorage.accessToken = res.data.token
          this.$store.commit('UPDATE_HEADERSHOW', true)
          this.$store.commit('UPDATE_DOCTORNAME', res.data.doctorName)
          this.$router.replace(this.$route.query.redirect || '/')
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
.login-bg {
  margin-top: 80px;
}
.hd-box {

}
</style>
